package com.ely.coupon.common.idempotent.controller;

import com.ely.coupon.common.idempotent.annotation.Idempotent;
import com.ely.coupon.common.idempotent.service.TokenService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 通过Token 判断
 * 请求头中
 */
@RestController
public class IdempotentTokenController {
    @Resource
    private TokenService tokenService;

    @GetMapping("/generate")
    public String generateToken(Long id) {
        tokenService.createToken(id);
        return "测试生成令牌成功";
    }

    @GetMapping("/verify")
    @Idempotent
    public String verifyToken(Long id) {
        return "校验token";
    }
}
